package com.zws.cucumber.optimization.socket.oio;

import com.zws.cucumber.optimization.socket.connector.ZwsConnectorAdaptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;
import java.nio.ByteBuffer;

public class ZwsSocketImpl extends SocketImpl {

    private static final Logger logger = LoggerFactory.getLogger(ZwsSocketImpl.class);

    private ZwsSocketInputStream inputStream;
    private ZwsSocketOutputStream outputStream;
    private ByteBuffer outputBuffer;

    public ZwsSocketImpl(ZwsConnectorAdaptor connectorAdaptor) {
        inputStream = new ZwsSocketInputStream(connectorAdaptor);
        outputStream = new ZwsSocketOutputStream();

        outputStream.setInputStream(inputStream);
        inputStream.setOutputStream(outputStream);
    }

    @Override
    protected void create(boolean stream) throws IOException {

    }

    @Override
    protected void connect(String host, int port) throws IOException {

    }

    @Override
    protected void connect(InetAddress address, int port) throws IOException {

    }

    @Override
    protected void connect(SocketAddress address, int timeout) throws IOException {

    }

    @Override
    protected void bind(InetAddress host, int port) throws IOException {

    }

    @Override
    protected void listen(int backlog) throws IOException {

    }

    @Override
    protected void accept(SocketImpl s) throws IOException {

    }

    @Override
    protected InputStream getInputStream() throws IOException {
        return inputStream;
    }

    @Override
    protected OutputStream getOutputStream() throws IOException {
        return outputStream;
    }

    @Override
    protected int available() throws IOException {
        return inputStream.available();
    }

    @Override
    protected void close() throws IOException {
        // should release resource
    }

    @Override
    protected void sendUrgentData(int data) throws IOException {

    }

    @Override
    public void setOption(int optID, Object value) throws SocketException {

    }

    @Override
    public Object getOption(int optID) throws SocketException {
        return null;
    }
}
